/*---------------------------------------------------------------------
 * File name: list.cpp
 *
 * Copyright (c) <2020-2022>, <ChenLong>
 *
 * All rights reserved.
 *
 * Author: ChenLong
 * Email: worldlong@foxmail.com
 *--------------------------------------------------------------------*/
#include "list.h"
/*
*/
void BList::insert(BListNode *node0, BListNode *new_node, char fb)
{
  if(number == 0) {
    node = new_node;
    number = 1;
    return;
  }
    
  if(fb == 'f') { //front
    new_node->next = node0;
    new_node->prev = node0->prev;
    node0->prev->next = new_node;
    node0->prev = new_node;
    number++;
  } else if(fb == 'b') {//behind
    new_node->next = node0->next;
    new_node->prev = node0;
    node0->next->prev = new_node;
    node0->next = new_node;
    number++;
  }
}
/*
*/
void BList::remove(BListNode *node0)
{
  if(number) {
    node0->prev->next = node0->next;
    node0->next->prev = node0->prev;
    number--;
  }  
}


